package com.hrt.util;

import java.util.Random;

public class RamUtil {
	/**
	 * 生成网页验证码
	 * @return
	 */
	public static String getRandomPwd(){
		  Random rd = new Random();
		  String n="";
		  int getNum;
		  do {
//		   getNum = Math.abs(rd.nextInt())%10 + 48;//产生数字0-9的随机数
		   getNum = Math.abs(rd.nextInt())%26 + 97;//产生字母a-z的随机数
		   char num1 = (char)getNum;
		   String dn = Character.toString(num1);
		   n += dn;
		  } while (n.length()<6);
		  return n;
}
	
	
	
	
	/**
	 * 生成手机验证码
	 * @return
	 */
	public static String getMobileVaildCode(){
		
		
		int count = 6;
	        char start = '0';
	        char end = '9';
	 
	        Random rnd = new Random();
	 
	        char[] result = new char[count];
	        int len = end - start + 1;
	 
	        while (count-- > 0) {
	            result[count] = (char) (rnd.nextInt(len) + start);
	        }
	 
	        return new String(result);
	  
	}
	public static void main(String[] args) {
		System.out.println(getRandomPwd());
	}
}
